
 <!DOCTYPE HTML>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
  <!-- Global Site Tag (gtag.js) - Google Analytics -->
  <script async src="https://www.googletagmanager.com/gtag/js?id=UA-84488915-1"></script>
  <script>
  window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

        gtag('config', 'UA-84488915-1');
  </script>
  
    <title>vim 命令大全 | linyu blog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="linyu">
    

    
    <meta name="description" content="第一级 – 存活 基本使用  i → Insert 模式，按 ESC 回到 Normal 模式.x → 删当前光标所在的一个字符。:wq → 存盘 + 退出 (:w 存盘, :q 退出)   （注：:w 后可以跟文件名）dd → 删除当前行，并把删除的行存到剪贴板里p → 粘贴剪贴板   推荐:  hjkl (强例推荐使用其移动光标，但不必需) →你也可以使用光标键 (←↓↑→). 注: j 就像">
<meta name="keywords" content="linux,vim">
<meta property="og:type" content="article">
<meta property="og:title" content="vim 命令大全">
<meta property="og:url" content="http://bigsuperangel.github.io/2016/06/01/linux-vim/index.html">
<meta property="og:site_name" content="linyu blog">
<meta property="og:description" content="第一级 – 存活 基本使用  i → Insert 模式，按 ESC 回到 Normal 模式.x → 删当前光标所在的一个字符。:wq → 存盘 + 退出 (:w 存盘, :q 退出)   （注：:w 后可以跟文件名）dd → 删除当前行，并把删除的行存到剪贴板里p → 粘贴剪贴板   推荐:  hjkl (强例推荐使用其移动光标，但不必需) →你也可以使用光标键 (←↓↑→). 注: j 就像">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-08-01T09:29:10.397Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="vim 命令大全">
<meta name="twitter:description" content="第一级 – 存活 基本使用  i → Insert 模式，按 ESC 回到 Normal 模式.x → 删当前光标所在的一个字符。:wq → 存盘 + 退出 (:w 存盘, :q 退出)   （注：:w 后可以跟文件名）dd → 删除当前行，并把删除的行存到剪贴板里p → 粘贴剪贴板   推荐:  hjkl (强例推荐使用其移动光标，但不必需) →你也可以使用光标键 (←↓↑→). 注: j 就像">

    
    <link rel="alternative" href="/atom.xml" title="linyu blog" type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/jacman.jpg">
    
    <link rel="stylesheet" href="/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/logo.png" alt="linyu blog" title="linyu blog"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="linyu blog">linyu blog</a></h1>
				<h2 class="blog-motto">Where there is a will,there is a way</h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜單">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/">Home</a></li>
					
						<li><a href="/archives">Archives</a></li>
					
						<li><a href="/tags/linux">linux</a></li>
					
						<li><a href="/tags/java">Java</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="搜索" />
						<input type="hidden" name="q" value="site:bigsuperangel.github.io">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2016/06/01/linux-vim/" title="vim 命令大全" itemprop="url">vim 命令大全</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="linyu" target="_blank" itemprop="author">linyu</a>
		
  <p class="article-time">
    <time datetime="2016-06-01T03:30:06.000Z" itemprop="datePublished"> 發表於 2016-06-01</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目錄</strong>
		
			<ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#第一级-–-存活"><span class="toc-number">1.</span> <span class="toc-text">第一级 – 存活</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#第二级-–-感觉良好"><span class="toc-number">2.</span> <span class="toc-text">第二级 – 感觉良好</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#第三级-超能力"><span class="toc-number">3.</span> <span class="toc-text">第三级-超能力</span></a></li></ol>
		
		</div>
		
		<h3 id="第一级-–-存活"><a href="#第一级-–-存活" class="headerlink" title="第一级 – 存活"></a>第一级 – 存活</h3><ol>
<li><p>基本使用</p>
<blockquote>
<p>i → Insert 模式，按 ESC 回到 Normal 模式.<br>x → 删当前光标所在的一个字符。<br>:wq → 存盘 + 退出 (:w 存盘, :q 退出)   （注：:w 后可以跟文件名）<br>dd → 删除当前行，并把删除的行存到剪贴板里<br>p → 粘贴剪贴板</p>
</blockquote>
</li>
<li><p>推荐:</p>
<blockquote>
<p>hjkl (强例推荐使用其移动光标，但不必需) →你也可以使用光标键 (←↓↑→). 注: j 就像下箭头。<br>:help <command> → 显示相关命令的帮助。你也可以就输入 :help 而不跟命令。（注：退出帮助需要输入:q）</p>
</blockquote>
</li>
</ol>
<h3 id="第二级-–-感觉良好"><a href="#第二级-–-感觉良好" class="headerlink" title="第二级 – 感觉良好"></a>第二级 – 感觉良好</h3><ol>
<li><p>各种插入模式</p>
<blockquote>
<p>a → 在光标后插入<br>o → 在当前行后插入一个新行<br>O → 在当前行前插入一个新行<br>cw → 替换从光标所在位置后到一个单词结尾的字符</p>
</blockquote>
</li>
<li><p>简单的移动光标</p>
<blockquote>
<p>0 → 数字零，到行头<br>^ → 到本行第一个不是blank字符的位置（所谓blank字符就是空格，tab，换行，回车等）<br>$ → 到本行行尾<br>g_ → 到本行最后一个不是blank字符的位置。<br>/pattern → 搜索 pattern 的字符串（注：如果搜索出多个匹配，可按n键到下一个）</p>
</blockquote>
</li>
<li><p>拷贝/粘贴 （注：p/P都可以，p是表示在当前位置之后，P表示在当前位置之前）</p>
<blockquote>
<p>P → 粘贴<br>yy → 拷贝当前行当行于 ddP</p>
</blockquote>
</li>
<li><p>Undo/Redo</p>
<blockquote>
<p>u → undo<br><c-r> → redo</c-r></p>
</blockquote>
</li>
<li><p>打开/保存/退出/改变文件(Buffer)</p>
<blockquote>
<p>:e <path to="" file=""></path> → 打开一个文件<br>:w → 存盘<br>:saveas <path to="" file=""></path> → 另存为 <path to="" file=""></path><br>:x， ZZ 或 :wq → 保存并退出 (:x 表示仅在需要时保存，ZZ不需要输入冒号并回车)<br>:q! → 退出不保存 :qa! 强行退出所有的正在编辑的文件，就算别的文件有更改。<br>:bn 和 :bp → 你可以同时打开很多文件，使用这两个命令来切换下一个或上一个文件。（注：我喜欢使用:n到下一个文件）</p>
</blockquote>
</li>
</ol>
<h3 id="第三级-超能力"><a href="#第三级-超能力" class="headerlink" title="第三级-超能力"></a>第三级-超能力</h3><ol>
<li><p>按键操作：</p>
<blockquote>
<p>注释：ctrl+v 进入列编辑模式,向下或向上移动光标,把需要注释的行的开头标记起来,然后按大写的I,再插入注释符,比如”#”,再按Esc,就会全部注释了。<br>删除：先按v,进入visual模式,横向选中列的个数(如”#”注释符号,需要选中两列),再按Esc,再按ctrl+v 进入列编辑模式,向下或向上移动光标,选中注释部分,然后按d, 就会删除注释符号（#）。<br>PS：当然不一定是shell的注释符”#”，也可以是”//“，或者其他任意的字符；vim才不知道什么是注释符呢，都是字符而已。</p>
</blockquote>
</li>
<li><p>使用替换命令：</p>
<blockquote>
<p>:% s/^/\/\//g     在全部内容的行首添加//号注释<br>:2,50 s/^/\/\//g  在2~50行首添加//号注释<br>:2,50 s/^\/\///g  在2~50行首删除//号</p>
</blockquote>
</li>
</ol>
  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">


  <div class="article-tags">
  
  <span></span> <a href="/tags/linux/">linux</a><a href="/tags/vim/">vim</a>
  </div>

</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://bigsuperangel.github.io/2016/06/01/linux-vim/" data-title="vim 命令大全 | linyu blog" data-tsina="null" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/2016/06/06/redis-command/" title="redis 相关命令">
  <strong>上一篇：</strong><br/>
  <span>
  redis 相关命令</span>
</a>
</div>


<div class="next">
<a href="/2016/06/01/ubuntu-root-pwd/"  title="ubuntu 默认 root 密码">
 <strong>下一篇：</strong><br/> 
 <span>ubuntu 默认 root 密码
</span>
</a>
</div>

</nav>

	
<section id="comments" class="comment">
	<div class="ds-thread" data-thread-key="2016/06/01/linux-vim/" data-title="vim 命令大全" data-url="http://bigsuperangel.github.io/2016/06/01/linux-vim/"></div>
</section>


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="顯示側邊欄"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目錄</strong>
 
 <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#第一级-–-存活"><span class="toc-number">1.</span> <span class="toc-text">第一级 – 存活</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#第二级-–-感觉良好"><span class="toc-number">2.</span> <span class="toc-text">第二级 – 感觉良好</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#第三级-超能力"><span class="toc-number">3.</span> <span class="toc-text">第三级-超能力</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隱藏側邊欄"></a></div>
<aside class="clearfix">

  
<div class="github-card">
<p class="asidetitle">Github 名片</p>
<div class="github-card" data-github="bigsuperangel" data-width="220" data-height="119" data-theme="medium">
<script type="text/javascript" src="//cdn.jsdelivr.net/github-cards/latest/widget.js" ></script>
</div>
  </div>



  

  
<div class="tagslist">
	<p class="asidetitle">標簽</p>
		<ul class="clearfix">
		
			
				<li><a href="/tags/linux/" title="linux">linux<sup>16</sup></a></li>
			
		
			
				<li><a href="/tags/ubuntu/" title="ubuntu">ubuntu<sup>11</sup></a></li>
			
		
			
				<li><a href="/tags/java/" title="java">java<sup>10</sup></a></li>
			
		
			
				<li><a href="/tags/maven/" title="maven">maven<sup>7</sup></a></li>
			
		
			
				<li><a href="/tags/mysql/" title="mysql">mysql<sup>4</sup></a></li>
			
		
			
				<li><a href="/tags/python/" title="python">python<sup>3</sup></a></li>
			
		
			
				<li><a href="/tags/tomcat/" title="tomcat">tomcat<sup>3</sup></a></li>
			
		
			
				<li><a href="/tags/alsamixer/" title="alsamixer">alsamixer<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/git/" title="git">git<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/hexo/" title="hexo">hexo<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/command/" title="command">command<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/eclipse/" title="eclipse">eclipse<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/doc命令/" title="doc命令">doc命令<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/database/" title="database">database<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/nodejs/" title="nodejs">nodejs<sup>2</sup></a></li>
			
		
			
				<li><a href="/tags/freenom/" title="freenom">freenom<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/gradle/" title="gradle">gradle<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/ignore/" title="ignore">ignore<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/security/" title="security">security<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/jitpack/" title="jitpack">jitpack<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="linkslist">
  <p class="asidetitle">友情鏈接</p>
    <ul>
        
          <li>
            
            	<a href="https://www.oschina.net" target="_blank" title="开源中国">开源中国</a>
            
          </li>
        
          <li>
            
            	<a href="http://stackoverflow.com" target="_blank" title="stackoverflow">stackoverflow</a>
            
          </li>
        
    </ul>
</div>

  


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS 訂閱</a>
</div>

  <div class="weiboshow">
  <p class="asidetitle">新浪微博</p>
    <iframe width="100%" height="119" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=119&fansRow=2&ptype=1&speed=0&skin=9&isTitle=1&noborder=1&isWeibo=0&isFans=0&uid=null&verifier=&dpc=1"></iframe>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> 知行合一 <br/>
			This is my blog,believe it or not.</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		
		<a href="https://github.com/bigsuperangel" target="_blank" class="icon-github" title="github"></a>
		
		
		
		
		
		
		
		
		
		<a href="mailto:bigsuperangel@gmail.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2019 
		
		<a href="/about" target="_blank" title="linyu">linyu</a>
		
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>
<script src="/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>



<script type="text/javascript">
  var duoshuoQuery = {short_name:"linyu"};
  (function() {
    var ds = document.createElement('script');
    ds.type = 'text/javascript';ds.async = true;
    ds.src = '//static.duoshuo.com/embed.js';
    ds.charset = 'UTF-8';
    (document.getElementsByTagName('head')[0] 
    || document.getElementsByTagName('body')[0]).appendChild(ds);
  })();
</script> 







<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-84488915-1', 'bigsuperangel.github.io');  
ga('send', 'pageview');
</script>





<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="返回頂部"><img src="/img/scrollup.png"/></a>
	</div>
	<script src="/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
